package com.lr.chat;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;
import java.net.UnknownHostException;

public class Client {

	public static void main(String[] args) throws UnknownHostException, IOException {
		//1.创建客户端,必须指定服务器地址以及端口，此时就已经在连接
		Socket client = new Socket("localhost",8888);
		
		BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
		System.out.println("-----------加入聊天室----------");
		System.out.print("请输入用户名：");
		String name = console.readLine();
		if(null == name || (" ").equals(name)){
			System.out.println("用户名输入错误");
			return;
		}
		
		Send send = new Send(client,name);
		Thread sendThread = new Thread(send);
		sendThread.start();
	    
		Recieve recieve = new Recieve(client);
		Thread recieveThread = new Thread(recieve);
		recieveThread.start();
		
	}

}
